/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package beans;

import db.dao.StudentDAO;
import javax.annotation.PostConstruct;
import javax.servlet.http.HttpSession;
import javax.faces.context.FacesContext;

/**
 *
 * This bean holds a users login data for the whole session.
 *
 * @author jonas
 */
public class LoginBean {
    static public final String MANGED_BEAN_NAME= "LoginBean";
    private String uname;
    private String pw;
    private long id;
    private boolean userLoggedIn;

    @PostConstruct
    public void init(){
        //uname = new String("arne.arnesson@gmail.com");
        //pw = new String("arne");
        userLoggedIn = false;
    }

    public boolean getUserLoggedIn(){
        return userLoggedIn;
    }
    public void setUserLoggedIn(boolean loggedIn){
        userLoggedIn = loggedIn;
    }
    
    public String getUname(){
        return uname;
    }
    public void setUname(String uname){
        this.uname = uname;
    }

    public String getPw(){
        return pw;
    }
    public void setPw(String pw){
        this.pw = pw;
    }

    public long getId(){
        return id;
    }
    public void setId(long id){
        this.id = id;
    }

    /*
     * Called after data has been submited to deterimine success of fail view
     */
    /*
    public Object navigate(){
        boolean pwCorrect = false;
        String storedPw = StudentDAO.searchForPw(uname);
        if(storedPw.equals(this.pw)){
            System.out.println("Password good!");
            pwCorrect = true;
        }
        
        if( pwCorrect ){
            userLoggedIn = true;
            return "main";
        }else{
            userLoggedIn = false;
            return "loginFail";
        }
    }
     */
}